package com.itheima.controller;

import com.github.pagehelper.Page;
import com.itheima.entity.PageResult;
import com.itheima.pojo.User;
import com.itheima.pojo.WebVisit;
import com.itheima.service.WebVisitService;
import com.itheima.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.persistence.Column;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/webVisit")
public class WebVisitController {

    @Autowired
    private WebVisitService webVisitService;

    @PostMapping("/getList")
    public Result getList(@RequestBody Map<String,Object> webVisitVO){
        Page<WebVisit> webVisitPage = webVisitService.findAll(webVisitVO);
        PageResult<WebVisit> pageResult=new PageResult<>();
        pageResult.setTotal(webVisitPage.getTotal());
        pageResult.setRecords(webVisitPage.getResult());
        pageResult.setSize((long) webVisitPage.getPageSize());
        pageResult.setCurrent((long) webVisitPage.getPageNum());
        pageResult.setOptimizeCountSql(true);
        pageResult.setSearchCount(true);
        return new Result("success",pageResult);
    }
}
